<?php
header("Content-type:text/html;charset=utf-8");
require_once "dbtools.inc.php";
$id=$_COOKIE['id'];
$correct_t=$_COOKIE['correct'];

$link = create_connection();
$sql = "select * from users where id=$id and status='normal'";
$result = @execute_sql($link,'zhihu',$sql);

$user = @mysqli_fetch_object($result)->username;
$user = $user.'thonsun123';
if ($correct_t!=md5($user)){
    @mysqli_free_result($result);
    @mysqli_close($link);
    header("location:login.php");
}
$question_id = isset($_GET['questionid'])?$_GET['questionid']:1;

$title=$_POST['header'];
$abstract=$_POST['abstract'];
$content=$_POST['content'];
$qtype=$_POST['qtype'];
$addtime = date("Y-m-d H:i:s",time());

if($title=="" or $abstract=="" or $content==""){
    echo "<script type='text/javascript'>alert('标题,摘要,内容不能为空');history.back();</script>";
}else{
    $sql = "update questions set qtypeid=$qtype,abstract='$abstract',title='$title',content='$content',addtime='$addtime'where id=$question_id";
    $result=execute_sql($link,'zhihu',$sql);
    @mysqli_free_result($result);
    @mysqli_close($link);
    echo "<script>alert('修改成功');</script>";
    echo "<script>window.location.href=\"profile.php\";</script>";
}
?>

